import quantities as quantities
import numpy as numpy

class UnitConverter():
    '''
    classdocs
    '''
    @classmethod
    def convertInto(self,value, unit):
        try:
            value.units = unit
        except:
            print "%s cannot be transformed into ""%s"" !"%(value,unit)
            value=-1
        return value
    
    @classmethod
    def convertIntoSI(self,value, unit):
        if type(value).__name__=='Quantity':
            value=value/unit
            value=value.simplified
            if value.dimensionality == quantities.dimensionless:
                value=value.magnitude
                if value.size>1:
                    return list(value)
                else:
                    return value
        return -1
